package pers.hl.module_main.admin.booktag

import pers.hl.common.base.BaseViewModel
import pers.hl.common.base.SingleLiveEvent
import pers.hl.lib_global.model.bean.BookTag

class TagManageViewModel: BaseViewModel<BaseTagModel>() {

    fun getAllTags(): SingleLiveEvent<List<BookTag>> {
        val allTagsEvent = SingleLiveEvent<List<BookTag>>()
        launchOnIO {
            val result = mModel.getAllTags()
            allTagsEvent.postValue(result.data)
        }
        return allTagsEvent
    }

    fun deleteTag(tagId: Int): SingleLiveEvent<*> {
        val deleteEvent = SingleLiveEvent<String>()
        launchOnIO {
            val result = mModel.deleteTag(listOf(tagId))
            deleteEvent.postValue(result.msg)
        }
        return deleteEvent
    }

}
